package com.zhoug.common.utils;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;

/**
 * 左面图表角标工具
 * @Author 35574
 * @Date 2021/3/2
 * @Description
 */
public class DesktopIconBadgeUtils {
    private static Application app;

    public static void init(Application app){
        DesktopIconBadgeUtils.app=app;
    }


    /**
     * 获取当前launcher包名
     * @return
     */
    public static String getLauncherPackageName() {
        final Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        final ResolveInfo res = app.getPackageManager().resolveActivity(intent, 0);
        if (res.activityInfo == null) {
            // should not happen. A home is always installed.
            return null;
        }
        if (res.activityInfo.packageName.equals("android")) {
            return null;
        } else {
            return res.activityInfo.packageName;
        }
    }



}
